stepper25 2.2.1
Loading...
Searching...
No Matches
stepper25


Stepper 25 Click

Stepper 25 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Feb 2025.
  • Type : SPI type

Software Support

Example Description

This example demonstrates the operation of the Stepper 25 Click board, which is used to control a bipolar stepper motor. The application initializes the board and executes different step modes, directions, and speeds to showcase precise motor control.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Stepper25

Example Key Functions

  • stepper25_cfg_setup This function initializes Click configuration structure to initial values.
    void stepper25_cfg_setup(stepper25_cfg_t *cfg)
    Stepper 25 configuration object setup function.
    Stepper 25 Click configuration object.
    Definition stepper25.h:381
  • stepper25_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t stepper25_init(stepper25_t *ctx, stepper25_cfg_t *cfg)
    Stepper 25 initialization function.
    Stepper 25 Click context object.
    Definition stepper25.h:357
  • stepper25_default_cfg Click Default Configuration function.
    err_t stepper25_default_cfg(stepper25_t *ctx)
    Stepper 25 default configuration function.
  • stepper25_set_direction This function sets the motor direction by setting the DIR pin logic state.
    void stepper25_set_direction ( stepper25_t *ctx, uint8_t dir );
    void stepper25_set_direction(stepper25_t *ctx, uint8_t dir)
    Stepper 25 set direction function.
  • stepper25_set_step_mode This function sets the step mode (microstepping level) of the Stepper 25 device.
    err_t stepper25_set_step_mode ( stepper25_t *ctx, uint8_t step_mode );
    err_t stepper25_set_step_mode(stepper25_t *ctx, uint8_t step_mode)
    Stepper 25 set step mode function.
  • stepper25_drive_motor This function drives the motor for the specific number of steps at the selected speed.
    err_t stepper25_drive_motor ( stepper25_t *ctx, uint32_t steps, uint8_t speed );
    err_t stepper25_drive_motor(stepper25_t *ctx, uint32_t steps, uint8_t speed)
    Stepper 25 driver motor function.

Application Init

Initializes the logger and Stepper 25 Click board. Configures the motor driver with default settings, preparing it for stepper motor control.

void application_init ( void )
{
log_cfg_t log_cfg;
stepper25_cfg_t stepper25_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
stepper25_cfg_setup( &stepper25_cfg );
if ( SPI_MASTER_ERROR == stepper25_init( &stepper25, &stepper25_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( STEPPER25_ERROR == stepper25_default_cfg ( &stepper25 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define STEPPER25_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition stepper25.h:339
void application_init(void)
Definition main.c:40
#define MIKROBUS_POSITION_STEPPER25
Definition main.c:34
@ STEPPER25_ERROR
Definition stepper25.h:408

Application Task

Moves the stepper motor in different step modes and directions at varying speeds. The motor completes a predefined number of steps in each mode, switching between clockwise (CW) and counterclockwise (CCW) directions with different step resolutions.

void application_task ( void )
{
log_printf ( &logger, " Step mode: 1/16\r\n" );
log_printf ( &logger, " Direction: CW\r\n" );
log_printf ( &logger, " Steps: 1600\r\n" );
log_printf ( &logger, " Speed: Medium\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Step mode: 1/8\r\n" );
log_printf ( &logger, " Direction: CCW\r\n" );
log_printf ( &logger, " Steps: 1600\r\n" );
log_printf ( &logger, " Speed: Fast\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Step mode: 1/4\r\n" );
log_printf ( &logger, " Direction: CW\r\n" );
log_printf ( &logger, " Steps: 400\r\n" );
log_printf ( &logger, " Speed: Slow\r\n\n" );
Delay_ms ( 1000 );
}
#define STEPPER25_SPEED_SLOW
Definition stepper25.h:307
#define STEPPER25_DIR_CW
Definition stepper25.h:293
#define STEPPER25_DIR_CCW
Stepper 25 direction setting.
Definition stepper25.h:292
#define STEPPER25_SPEED_FAST
Definition stepper25.h:309
#define STEPPER25_SPEED_MEDIUM
Definition stepper25.h:308
#define STEPPER25_STEP_MODE_QUARTER
Definition stepper25.h:280
#define STEPPER25_STEP_MODE_1_OVER_16
Definition stepper25.h:282
#define STEPPER25_STEP_MODE_1_OVER_8
Definition stepper25.h:281
void application_task(void)
Definition main.c:76

Note

Ensure proper power supply and motor connections before running the example.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.